home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / CIncludes / OSA.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-11  |  54.3 KB  |  1,598 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        OSA.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __OSA__
  18. #define __OSA__
  19.  
  20.  
  21. #ifndef __ERRORS__
  22. #include <Errors.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifndef __APPLEEVENTS__
  27. #include <AppleEvents.h>
  28. #endif
  29. /*    #include <Types.h>                                            */
  30. /*    #include <Memory.h>                                            */
  31. /*        #include <MixedMode.h>                                    */
  32. /*    #include <OSUtils.h>                                        */
  33. /*    #include <Events.h>                                            */
  34. /*        #include <Quickdraw.h>                                    */
  35. /*            #include <QuickdrawText.h>                            */
  36. /*    #include <EPPC.h>                                            */
  37. /*        #include <PPCToolbox.h>                                    */
  38. /*            #include <AppleTalk.h>                                */
  39. /*        #include <Processes.h>                                    */
  40. /*            #include <Files.h>                                    */
  41. /*    #include <Notification.h>                                    */
  42.  
  43. #ifndef __AEOBJECTS__
  44. #include <AEObjects.h>
  45. #endif
  46.  
  47. #ifndef __COMPONENTS__
  48. #include <Components.h>
  49. #endif
  50.  
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54.  
  55. #if GENERATINGPOWERPC
  56. #pragma options align=mac68k
  57. #endif
  58.  
  59. #ifdef __CFM68K__
  60. #pragma lib_export on
  61. #endif
  62.  
  63.  
  64. enum {
  65.     kOSAComponentType            = 'osa '
  66. };
  67.  
  68. /* 0x73637074 */
  69. enum {
  70.     kOSAGenericScriptingComponentSubtype = 'scpt'
  71. };
  72.  
  73. /*    Type of script document files.    */
  74. /* 0x6f736173 */
  75. enum {
  76.     kOSAFileType                = 'osas'
  77. };
  78.  
  79. /*
  80.         Suite and event code of the RecordedText event. 
  81.         (See OSAStartRecording, below.)
  82.     */
  83. /* 0x61736372 */
  84. enum {
  85.     kOSASuite                    = 'ascr'
  86. };
  87.  
  88. /* 0x72656364 */
  89. enum {
  90.     kOSARecordedText            = 'recd'
  91. };
  92.  
  93. /* Selector returns boolean */
  94. /* 0x6d6f6469 */
  95. enum {
  96.     kOSAScriptIsModified        = 'modi'
  97. };
  98.  
  99. /* Selector returns boolean */
  100. /* 0x63736372 */
  101. enum {
  102.     kOSAScriptIsTypeCompiledScript = 'cscr'
  103. };
  104.  
  105. /* Selector returns boolean */
  106. /* 0x76616c75 */
  107. enum {
  108.     kOSAScriptIsTypeScriptValue    = 'valu'
  109. };
  110.  
  111. /* Selector returns boolean */
  112. /* 0x636e7478 */
  113. enum {
  114.     kOSAScriptIsTypeScriptContext = 'cntx'
  115. };
  116.  
  117. /* Selector returns a DescType which may be passed to OSACoerceToDesc */
  118. /* 0x62657374 */
  119. enum {
  120.     kOSAScriptBestType            = 'best'
  121. };
  122.  
  123. /*
  124.         This selector is used to determine whether a script has source 
  125.         associated with it that when given to OSAGetSource, the call will not
  126.         fail.  The selector returns a boolean.
  127.     */
  128. /* 0x67737263 */
  129. enum {
  130.     kOSACanGetSource            = 'gsrc'
  131. };
  132.  
  133. enum {
  134.     typeOSADialectInfo            = 'difo',                        /*  0x6469666f   */
  135.     keyOSADialectName            = 'dnam',                        /*  0x646e616d   */
  136.     keyOSADialectCode            = 'dcod',                        /*  0x64636f64   */
  137.     keyOSADialectLangCode        = 'dlcd',                        /*  0x646c6364   */
  138.     keyOSADialectScriptCode        = 'dscd'
  139. };
  140.  
  141. typedef ComponentResult OSAError;
  142.  
  143. /* Under the Open Scripting Architecture all error results are longs */
  144. typedef unsigned long OSAID;
  145.  
  146. /*
  147.         OSAIDs allow transparent manipulation of scripts associated with
  148.          various scripting systems.
  149.     */
  150.  
  151. enum {
  152.     kOSANullScript                = (OSAID)0
  153. };
  154.  
  155. /* No -script constant. */
  156. enum {
  157.     kOSANullMode                = 0,                            /* sounds better */
  158.     kOSAModeNull                = 0                                /* tastes consistent */
  159. };
  160.  
  161. /*
  162.         Some routines take flags that control their execution.  This constant
  163.         declares default mode settings are used.
  164.     */
  165. typedef pascal OSErr (*OSACreateAppleEventProcPtr)(AEEventClass theAEEventClass, AEEventID theAEEventID, const AEAddressDesc *target, short returnID, long transactionID, AppleEvent *result, long refCon);
  166.  
  167. #if GENERATINGCFM
  168. typedef UniversalProcPtr OSACreateAppleEventUPP;
  169. #else
  170. typedef OSACreateAppleEventProcPtr OSACreateAppleEventUPP;
  171. #endif
  172.  
  173. enum {
  174.     uppOSACreateAppleEventProcInfo = kPascalStackBased
  175.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  176.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(AEEventClass)))
  177.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(AEEventID)))
  178.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(AEAddressDesc*)))
  179.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short)))
  180.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
  181.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(AppleEvent*)))
  182.          | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(long)))
  183. };
  184.  
  185. #if GENERATINGCFM
  186. #define NewOSACreateAppleEventProc(userRoutine)        \
  187.         (OSACreateAppleEventUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSACreateAppleEventProcInfo, GetCurrentArchitecture())
  188. #else
  189. #define NewOSACreateAppleEventProc(userRoutine)        \
  190.         ((OSACreateAppleEventUPP) (userRoutine))
  191. #endif
  192.  
  193. #if GENERATINGCFM
  194. #define CallOSACreateAppleEventProc(userRoutine, theAEEventClass, theAEEventID, target, returnID, transactionID, result, refCon)        \
  195.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppOSACreateAppleEventProcInfo, (theAEEventClass), (theAEEventID), (target), (returnID), (transactionID), (result), (refCon))
  196. #else
  197. #define CallOSACreateAppleEventProc(userRoutine, theAEEventClass, theAEEventID, target, returnID, transactionID, result, refCon)        \
  198.         (*(userRoutine))((theAEEventClass), (theAEEventID), (target), (returnID), (transactionID), (result), (refCon))
  199. #endif
  200.  
  201. typedef pascal OSErr (*OSASendProcPtr)(const AppleEvent *theAppleEvent, AppleEvent *reply, AESendMode sendMode, AESendPriority sendPriority, long timeOutInTicks, AEIdleUPP idleProc, AEFilterUPP filterProc, long refCon);
  202.  
  203. #if GENERATINGCFM
  204. typedef UniversalProcPtr OSASendUPP;
  205. #else
  206. typedef OSASendProcPtr OSASendUPP;
  207. #endif
  208.  
  209. enum {
  210.     uppOSASendProcInfo = kPascalStackBased
  211.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  212.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(AppleEvent*)))
  213.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(AppleEvent*)))
  214.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(AESendMode)))
  215.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(AESendPriority)))
  216.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(long)))
  217.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(AEIdleProcPtr)))
  218.          | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(AEFilterProcPtr)))
  219.          | STACK_ROUTINE_PARAMETER(8, SIZE_CODE(sizeof(long)))
  220. };
  221.  
  222. #if GENERATINGCFM
  223. #define NewOSASendProc(userRoutine)        \
  224.         (OSASendUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSASendProcInfo, GetCurrentArchitecture())
  225. #else
  226. #define NewOSASendProc(userRoutine)        \
  227.         ((OSASendUPP) (userRoutine))
  228. #endif
  229.  
  230. #if GENERATINGCFM
  231. #define CallOSASendProc(userRoutine, theAppleEvent, reply, sendMode, sendPriority, timeOutInTicks, idleProc, filterProc, refCon)        \
  232.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppOSASendProcInfo, (theAppleEvent), (reply), (sendMode), (sendPriority), (timeOutInTicks), (idleProc), (filterProc), (refCon))
  233. #else
  234. #define CallOSASendProc(userRoutine, theAppleEvent, reply, sendMode, sendPriority, timeOutInTicks, idleProc, filterProc, refCon)        \
  235.         (*(userRoutine))((theAppleEvent), (reply), (sendMode), (sendPriority), (timeOutInTicks), (idleProc), (filterProc), (refCon))
  236. #endif
  237.  
  238. /**************************************************************************
  239.     Standard Script Errors
  240. **************************************************************************
  241.     It is recommended that scripting components use the following set of error
  242.     codes to signal failure when applicable.  This enables applications that
  243.     use the OSA API to deal with some class of script errors in a less than 
  244.     ad hoc manner.  Scripting components are of course encouraged to return
  245.     component-specific errors when these don't apply.
  246. **************************************************************************/
  247. /*        Dynamic errors:
  248.  
  249.     These errors result from data-dependent conditions and are typically
  250.     signaled at runtime.
  251. */
  252. /*
  253.         Signaled when a value can't be coerced to the desired type. Similar
  254.           to errOSATypeError except results from coercion.
  255.     */
  256. enum {
  257.     errOSACantCoerce            = errAECoercionFail
  258. };
  259.  
  260. /* Signaled when an object is not found in a container */
  261. enum {
  262.     errOSACantAccess            = errAENoSuchObject
  263. };
  264.  
  265. /*
  266.         Signaled when an object cannot be set in a container.  Same as 
  267.           AERegistry error errAEWriteDenied.
  268.     */
  269. enum {
  270.     errOSACantAssign            = -10006
  271. };
  272.  
  273. /*
  274.         Signaled by user scripts or applications when no actual error code
  275.           is to be returned.  Simply means "an error has occurred".  Most useful
  276.           in conjunction with an error message from the application.
  277.     */
  278. enum {
  279.     errOSAGeneralError            = -2700
  280. };
  281.  
  282. /* Signaled when there is an attempt to divide by zero */
  283. enum {
  284.     errOSADivideByZero            = -2701
  285. };
  286.  
  287. /* Signaled when integer or real value is too large to be represented */
  288. enum {
  289.     errOSANumericOverflow        = -2702
  290. };
  291.  
  292. /*
  293.         Signaled when application can't be launched or when it is remote and
  294.           program linking is not enabled.
  295.     */
  296. enum {
  297.     errOSACantLaunch            = -2703
  298. };
  299.  
  300. /* Signaled when an application can't respond to AppleEvents */
  301. enum {
  302.     errOSAAppNotHighLevelEventAware = -2704
  303. };
  304.  
  305. /* Signaled when an application's terminology resource is not readable */
  306. enum {
  307.     errOSACorruptTerminology    = -2705
  308. };
  309.  
  310. /* Signaled when the runtime stack overflows */
  311. enum {
  312.     errOSAStackOverflow            = -2706
  313. };
  314.  
  315. /* Signaled when a runtime internal data structure overflows */
  316. enum {
  317.     errOSAInternalTableOverflow    = -2707
  318. };
  319.  
  320. /*
  321.         Signaled when an intrinsic limitation is exceeded for the size of 
  322.           a value or data structure.
  323.     */
  324. enum {
  325.     errOSADataBlockTooLarge        = -2708
  326. };
  327.  
  328. enum {
  329.     errOSACantGetTerminology    = -2709
  330. };
  331.  
  332. enum {
  333.     errOSACantCreate            = -2710
  334. };
  335.  
  336. /*        Component-specific dynamic script errors:
  337.  
  338.     The range -2720 thru -2739 is reserved for component-specific runtime errors.
  339.     (Note that error codes from different scripting components in this range will
  340.     overlap.)
  341. */
  342. /*        Static errors:
  343.  
  344.     These errors comprise what are commonly thought of as parse and compile-
  345.     time errors.  However, in a dynamic system (e.g. AppleScript) any or all
  346.     of these may also occur at runtime.
  347. */
  348. /* Signaled when data was not the right type and coercion is not allowed */
  349. enum {
  350.     errOSATypeError                = errAEWrongDataType
  351. };
  352.  
  353. /* Signaled when a message was sent to an object that didn't handle it */
  354. enum {
  355.     OSAMessageNotUnderstood        = errAEEventNotHandled
  356. };
  357.  
  358. /*
  359.         Signaled when a function to be returned doesn't exist.  (Probably only
  360.           useful in languages with first-class functions that distinguish between
  361.           functions and other values (two name spaces). This is different from
  362.           errOSAMessageNotUnderstood, which may be signaled when the method is
  363.           invoked.
  364.     */
  365. enum {
  366.     OSAUndefinedHandler            = errAEHandlerNotFound
  367. };
  368.  
  369. /* Signaled when a container can never have the requested object */
  370. enum {
  371.     OSAIllegalAccess            = errAEAccessorNotFound
  372. };
  373.  
  374. /* Signaled when index was out of range. Specialization of errOSACantAccess. */
  375. enum {
  376.     OSAIllegalIndex                = errAEIllegalIndex
  377. };
  378.  
  379. /* Signaled when a range is screwy. Specialization of errOSACantAccess. */
  380. enum {
  381.     OSAIllegalRange                = errAEImpossibleRange
  382. };
  383.  
  384. /*
  385.         Signaled when an object can never be set in a container.  Same as 
  386.           AERegistry error errAENotModifiable.
  387.     */
  388. enum {
  389.     OSAIllegalAssign            = -10003
  390. };
  391.  
  392. /*
  393.         Signaled when a syntax error occurs. (e.g. "Syntax error" or
  394.          "<this> can't go after <that>").
  395.     */
  396. enum {
  397.     OSASyntaxError                = -2740
  398. };
  399.  
  400. /*
  401.         Signaled when another form of syntax was expected. (e.g. "expected
  402.           a <type> but found <this>").
  403.     */
  404. enum {
  405.     OSASyntaxTypeError            = -2741
  406. };
  407.  
  408. /* Signaled when a name or number is too long to be parsed */
  409. enum {
  410.     OSATokenTooLong                = -2742
  411. };
  412.  
  413. /*
  414.         Signaled when a parameter is missing for a function invocation.  Note
  415.           that in some languages, this error may occur at runtime.
  416.     */
  417. enum {
  418.     OSAMissingParameter            = errAEDescNotFound
  419. };
  420.  
  421. /*
  422.         Signaled when function is called with the wrong number of parameters,
  423.           or a parameter pattern cannot be matched.
  424.     */
  425. enum {
  426.     OSAParameterMismatch        = errAEWrongNumberArgs
  427. };
  428.  
  429. /*
  430.         Signaled when a formal parameter, local variable, or instance variable
  431.           is specified more than once.
  432.     */
  433. enum {
  434.     OSADuplicateParameter        = -2750
  435. };
  436.  
  437. /*
  438.         Signaled when a formal parameter, local variable, or instance variable
  439.           is specified more than once.
  440.     */
  441. enum {
  442.     OSADuplicateProperty        = -2751
  443. };
  444.  
  445. /*
  446.         Signaled when more than one handler is defined with the same name in 
  447.           a scope where the language doesn't allow it.
  448.     */
  449. enum {
  450.     OSADuplicateHandler            = -2752
  451. };
  452.  
  453. /* Signaled when a variable is accessed that has no value */
  454. enum {
  455.     OSAUndefinedVariable        = -2753
  456. };
  457.  
  458. /*
  459.         Signaled when a variable is declared inconsistently in the same scope,
  460.           such as both local and global.
  461.     */
  462. enum {
  463.     OSAInconsistentDeclarations    = -2754
  464. };
  465.  
  466. /*
  467.         Signaled when illegal control flow occurs in an application (no catcher
  468.           for throw, non-lexical loop exit, etc.).
  469.     */
  470. enum {
  471.     OSAControlFlowError            = -2755
  472. };
  473.  
  474. /*        Component-specific static script errors:
  475.  
  476.     The range -2760 thru -2779 is reserved for component-specific parsing and
  477.     compile-time errors. (Note that error codes from different scripting
  478.     components in this range will overlap.)
  479. */
  480. /*        Dialect-specific script errors:
  481.  
  482.     The range -2780 thru -2799 is reserved for dialect specific error codes for
  483.     scripting components that support dialects. (Note that error codes from
  484.     different scripting components in this range will overlap, as well as error
  485.     codes from different dialects in the same scripting component.)
  486. */
  487. /**************************************************************************
  488.     OSA Interface Descriptions
  489. **************************************************************************
  490.     The OSA Interface is broken down into a required interface, and several
  491.     optional interfaces to support additional functionality.  A given scripting
  492.     component may choose to support only some of the optional interfaces in
  493.     addition to the basic interface.  The OSA Component Flags may be used to 
  494.     query the Component Manager to find a scripting component with a particular
  495.     capability, or determine if a particular scripting component supports a 
  496.     particular capability.
  497. **************************************************************************/
  498. /* OSA Component Flags: */
  499. enum {
  500.     kOSASupportsCompiling        = 0x0002,
  501.     kOSASupportsGetSource        = 0x0004,
  502.     kOSASupportsAECoercion        = 0x0008,
  503.     kOSASupportsAESending        = 0x0010,
  504.     kOSASupportsRecording        = 0x0020,
  505.     kOSASupportsConvenience        = 0x0040,
  506.     kOSASupportsDialects        = 0x0080,
  507.     kOSASupportsEventHandling    = 0x0100
  508. };
  509.  
  510. /* Component Selectors: */
  511. enum {
  512.     kOSASelectLoad                = 0x0001,
  513.     kOSASelectStore                = 0x0002,
  514.     kOSASelectExecute            = 0x0003,
  515.     kOSASelectDisplay            = 0x0004,
  516.     kOSASelectScriptError        = 0x0005,
  517.     kOSASelectDispose            = 0x0006,
  518.     kOSASelectSetScriptInfo        = 0x0007,
  519.     kOSASelectGetScriptInfo        = 0x0008,
  520.     kOSASelectSetActiveProc        = 0x0009,
  521.     kOSASelectGetActiveProc        = 0x000A
  522. };
  523.  
  524. /* Compiling: */
  525. enum {
  526.     kOSASelectScriptingComponentName = 0x0102,
  527.     kOSASelectCompile            = 0x0103,
  528.     kOSASelectCopyID            = 0x0104
  529. };
  530.  
  531. /* GetSource: */
  532. enum {
  533.     kOSASelectGetSource            = 0x0201
  534. };
  535.  
  536. /* AECoercion: */
  537. enum {
  538.     kOSASelectCoerceFromDesc    = 0x0301,
  539.     kOSASelectCoerceToDesc        = 0x0302
  540. };
  541.  
  542. /* AESending: */
  543. enum {
  544.     kOSASelectSetSendProc        = 0x0401,
  545.     kOSASelectGetSendProc        = 0x0402,
  546.     kOSASelectSetCreateProc        = 0x0403,
  547.     kOSASelectGetCreateProc        = 0x0404,
  548.     kOSASelectSetDefaultTarget    = 0x0405
  549. };
  550.  
  551. /* Recording: */
  552. enum {
  553.     kOSASelectStartRecording    = 0x0501,
  554.     kOSASelectStopRecording        = 0x0502
  555. };
  556.  
  557. /* Convenience: */
  558. enum {
  559.     kOSASelectLoadExecute        = 0x0601,
  560.     kOSASelectCompileExecute    = 0x0602,
  561.     kOSASelectDoScript            = 0x0603
  562. };
  563.  
  564. /* Dialects: */
  565. enum {
  566.     kOSASelectSetCurrentDialect    = 0x0701,
  567.     kOSASelectGetCurrentDialect    = 0x0702,
  568.     kOSASelectAvailableDialects    = 0x0703,
  569.     kOSASelectGetDialectInfo    = 0x0704,
  570.     kOSASelectAvailableDialectCodeList = 0x0705
  571. };
  572.  
  573. /* Event Handling: */
  574. enum {
  575.     kOSASelectSetResumeDispatchProc = 0x0801,
  576.     kOSASelectGetResumeDispatchProc = 0x0802,
  577.     kOSASelectExecuteEvent        = 0x0803,
  578.     kOSASelectDoEvent            = 0x0804,
  579.     kOSASelectMakeContext        = 0x0805
  580. };
  581.  
  582. /* scripting component specific selectors are added beginning with this value  */
  583. enum {
  584.     kOSASelectComponentSpecificStart = 0x1001
  585. };
  586.  
  587. /*        Mode Flags:
  588.  
  589.     Warning: These should not conflict with the AESend mode flags in
  590.     AppleEvents.h, because we may want to use them as OSA mode flags too.
  591. */
  592. /*
  593.         This mode flag may be passed to OSALoad, OSAStore or OSACompile to
  594.           instruct the scripting component to not retain the "source" of an
  595.           expression.  This will cause the OSAGetSource call to return the error
  596.           errOSASourceNotAvailable if used.  However, some scripting components
  597.           may not retain the source anyway.  This is mainly used when either space
  598.           efficiency is desired, or a script is to be "locked" so that its
  599.           implementation may not be viewed.
  600.     */
  601. enum {
  602.     kOSAModePreventGetSource    = 0x00000001
  603. };
  604.  
  605. /*
  606.         These mode flags may be passed to OSACompile, OSAExecute, OSALoadExecute
  607.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  608.           indicate whether or not the script may interact with the user, switch
  609.           layer or reconnect if necessary.  Any AppleEvents will be sent with the
  610.           corresponding AESend mode supplied.
  611.     */
  612. enum {
  613.     kOSAModeNeverInteract        = kAENeverInteract,
  614.     kOSAModeCanInteract            = kAECanInteract,
  615.     kOSAModeAlwaysInteract        = kAEAlwaysInteract,
  616.     kOSAModeDontReconnect        = kAEDontReconnect
  617. };
  618.  
  619. /*
  620.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  621.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  622.           indicate whether or not AppleEvents should be sent with the
  623.           kAECanSwitchLayer mode flag sent or not. NOTE: This flag is exactly the
  624.           opposite sense of the AppleEvent flag kAECanSwitchLayer.  This is to
  625.           provide a more convenient default, i.e. not supplying any mode
  626.           (kOSAModeNull) means to send events with kAECanSwitchLayer.  Supplying
  627.           the kOSAModeCantSwitchLayer mode flag will cause AESend to be called
  628.           without kAECanSwitchLayer.
  629.     */
  630. enum {
  631.     kOSAModeCantSwitchLayer        = 0x00000040
  632. };
  633.  
  634. /*
  635.         This mode flag may be passed to OSACompile, OSAExecute, OSALoadExecute
  636.           OSACompileExecute, OSADoScript, OSAExecuteEvent, or OSADoEvent to
  637.           indicate whether or not AppleEvents should be sent with the kAEDontRecord
  638.           mode flag sent or not. NOTE: This flag is exactly the opposite sense of
  639.           the AppleEvent flag kAEDontRecord.  This is to provide a more convenient
  640.           default, i.e. not supplying any mode (kOSAModeNull) means to send events
  641.           with kAEDontRecord.  Supplying the kOSAModeDoRecord mode flag will 
  642.           cause AESend to be called without kAEDontRecord.
  643.     */
  644. enum {
  645.     kOSAModeDoRecord            = 0x00001000
  646. };
  647.  
  648. /*
  649.         This is a mode flag for OSACompile that indicates that a context should
  650.           be created as the result of compilation. All handler definitions are
  651.           inserted into the new context, and variables are initialized by
  652.           evaluating their initial values in a null context (i.e. they must be
  653.           constant expressions).
  654.     */
  655. enum {
  656.     kOSAModeCompileIntoContext    = 0x00000002
  657. };
  658.  
  659. /*
  660.         This is a mode flag for OSACompile that indicates that the previous
  661.           script ID (input to OSACompile) should be augmented with any new
  662.           definitions in the sourceData rather than replaced with a new script.
  663.           This means that the previous script ID must designate a context.
  664.           The presence of this flag causes the kOSAModeCompileIntoContext flag
  665.           to be implicitly used, causing any new definitions to be initialized
  666.           in a null context.
  667.     */
  668. enum {
  669.     kOSAModeAugmentContext        = 0x00000004
  670. };
  671.  
  672. /*
  673.         This mode flag may be passed to OSADisplay or OSADoScript to indicate
  674.           that output only need be human-readable, not re-compilable by OSACompile.
  675.           If used, output may be arbitrarily "beautified", e.g. quotes may be left
  676.           off of string values, long lists may have elipses, etc.
  677.     */
  678. enum {
  679.     kOSAModeDisplayForHumans    = 0x00000008
  680. };
  681.  
  682. /*
  683.         This mode flag may be passed to OSAStore in the case where the scriptID
  684.           is a context.  This causes the context to be saved, but not the context's
  685.           parent context.  When the stored context is loaded back in, the parent
  686.           will be kOSANullScript.
  687.     */
  688. enum {
  689.     kOSAModeDontStoreParent        = 0x00010000
  690. };
  691.  
  692. /*
  693.         This mode flag may be passed to OSAExecuteEvent to cause the event to
  694.           be dispatched to the direct object of the event. The direct object (or
  695.           subject attribute if the direct object is a non-object specifier) will
  696.           be resolved, and the resulting script object will be the recipient of
  697.           the message. The context argument to OSAExecuteEvent will serve as the
  698.           root of the lookup/resolution process.
  699.     */
  700. enum {
  701.     kOSAModeDispatchToDirectObject = 0x00020000
  702. };
  703.  
  704. /*
  705.         This mode flag may be passed to OSAExecuteEvent to indicate that
  706.           components do not have to get the data of object specifier arguments.
  707.     */
  708. enum {
  709.     kOSAModeDontGetDataForArguments = 0x00040000
  710. };
  711.  
  712. /**************************************************************************
  713.     OSA Basic Scripting Interface
  714. **************************************************************************
  715.     Scripting components must at least support the Basic Scripting interface.
  716. **************************************************************************/
  717. /*        Loading and Storing Scripts:
  718.  
  719.     These routines allow scripts to be loaded and stored in their internal
  720.     (possibly compiled, non-text) representation.
  721. */
  722. /* Resource type for scripts */
  723. enum {
  724.     kOSAScriptResourceType        = kOSAGenericScriptingComponentSubtype
  725. };
  726.  
  727. /*
  728.         Default type given to OSAStore which creates "generic" loadable script
  729.           data descriptors.
  730.     */
  731. enum {
  732.     typeOSAGenericStorage        = kOSAScriptResourceType
  733. };
  734.  
  735. extern pascal OSAError OSALoad(ComponentInstance scriptingComponent, const AEDesc *scriptData, long modeFlags, OSAID *resultingScriptID)
  736.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0001, 0x7000, 0xA82A);
  737. /*
  738.         OSAComponentFunctionInline(kOSASelectLoad, 12);
  739.     
  740.         Errors:
  741.             badComponentInstance        invalid scripting component instance
  742.             errOSASystemError
  743.             errOSABadStorageType:        scriptData not for this scripting component
  744.             errOSACorruptData:            data seems to be corrupt
  745.             errOSADataFormatObsolete    script data format is no longer supported
  746.             errOSADataFormatTooNew        script data format is from a newer version
  747.         
  748.         ModeFlags:
  749.             kOSAModePreventGetSource
  750.     */
  751. extern pascal OSAError OSAStore(ComponentInstance scriptingComponent, OSAID scriptID, DescType desiredType, long modeFlags, AEDesc *resultingScriptData)
  752.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0002, 0x7000, 0xA82A);
  753. /*
  754.         OSAComponentFunctionInline(kOSASelectStore, 16);
  755.     
  756.         Errors:
  757.             badComponentInstance    invalid scripting component instance
  758.             errOSASystemError
  759.             errOSAInvalidID
  760.             errOSABadStorageType:    desiredType not for this scripting component
  761.         
  762.         ModeFlags:
  763.             kOSAModePreventGetSource
  764.             kOSAModeDontStoreParent
  765.     */
  766. /* Executing Scripts: */
  767. extern pascal OSAError OSAExecute(ComponentInstance scriptingComponent, OSAID compiledScriptID, OSAID contextID, long modeFlags, OSAID *resultingScriptValueID)
  768.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0003, 0x7000, 0xA82A);
  769. /*
  770.         OSAComponentFunctionInline(kOSASelectExecute, 16);
  771.         This call runs a script.  The contextID represents the environment
  772.         with which global variables in the script are resolved.  The constant
  773.         kOSANullScript may be used for the contextID if the application wishes
  774.         to not deal with context directly (a default one is associated with each
  775.         scripting component instance).  The resultingScriptValueID is the 
  776.         result of evaluation, and contains a value which may be displayed using
  777.         the OSAGetSource call.  The modeFlags convey scripting component
  778.         specific information.
  779.     
  780.         Errors:
  781.             badComponentInstance    invalid scripting component instance
  782.             errOSASystemError
  783.             errOSAInvalidID
  784.             errOSAScriptError:        the executing script got an error
  785.     
  786.         ModeFlags:
  787.             kOSAModeNeverInteract
  788.             kOSAModeCanInteract
  789.             kOSAModeAlwaysInteract
  790.             kOSAModeCantSwitchLayer
  791.             kOSAModeDontReconnect
  792.             kOSAModeDoRecord
  793.     */
  794. /* Displaying results: */
  795. extern pascal OSAError OSADisplay(ComponentInstance scriptingComponent, OSAID scriptValueID, DescType desiredType, long modeFlags, AEDesc *resultingText)
  796.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0004, 0x7000, 0xA82A);
  797. /*
  798.         OSAComponentFunctionInline(kOSASelectDisplay, 16);
  799.         This call is used to convert results (script value IDs) into displayable
  800.         text. The desiredType should be at least typeChar, and modeFlags are
  801.         scripting system specific flags to control the formatting of the
  802.         resulting text. This call differs from OSAGetSource in that (1) it
  803.         always produces at least typeChar, (2) is only works on script values,
  804.         (3) it may display it's output in non-compilable form (e.g. without
  805.         string quotes, elipses inserted in long and/or circular lists, etc.) and
  806.         (4) it is required by the basic scripting interface.
  807.     
  808.         Errors:
  809.             badComponentInstance    invalid scripting component instance
  810.             errOSASystemError
  811.             errOSAInvalidID
  812.             errAECoercionFail:        desiredType not supported by scripting component
  813.     
  814.         ModeFlags:
  815.             kOSAModeDisplayForHumans
  816.     */
  817. /* Getting Error Information: */
  818. extern pascal OSAError OSAScriptError(ComponentInstance scriptingComponent, OSType selector, DescType desiredType, AEDesc *resultingErrorDescription)
  819.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0005, 0x7000, 0xA82A);
  820. /*
  821.         OSAComponentFunctionInline(kOSASelectScriptError, 12);
  822.         Whenever script execution returns errOSAExecutionError, this routine
  823.         may be used to get information about that error.  The selector describes
  824.         the type of information desired about the error (various selectors are
  825.         listed below).  The desiredType indicates the data type of the result
  826.         desired for that selector.
  827.     
  828.         Errors:
  829.             badComponentInstance    invalid scripting component instance
  830.             errOSASystemError
  831.             errOSABadSelector:        selector not supported by scripting component
  832.             errAECoercionFail:        desiredType not supported by scripting component
  833.     */
  834. /* OSAScriptError selectors: */
  835. /*
  836.         This selector is used to determine the error number of a script error.
  837.         These error numbers may be either system error numbers, or error numbers
  838.         that are scripting component specific.
  839.         Required desiredTypes:    
  840.               typeShortInteger
  841.     */
  842.  
  843. enum {
  844.     kOSAErrorNumber                = keyErrorNumber
  845. };
  846.  
  847. /*
  848.         This selector is used to determine the full error message associated
  849.         with the error number.  It should include the name of the application
  850.         which caused the error, as well as the specific error that occurred.
  851.         This selector is sufficient for simple error reporting (but see
  852.         kOSAErrorBriefMessage, below).
  853.         Required desiredTypes:
  854.             typeChar                    error message string
  855.     */
  856. enum {
  857.     kOSAErrorMessage            = keyErrorString
  858. };
  859.  
  860. /*
  861.         This selector is used to determine a brief error message associated with
  862.         the error number.  This message and should not mention the name of the
  863.         application which caused the error, any partial results or offending
  864.         object (see kOSAErrorApp, kOSAErrorPartialResult and
  865.         kOSAErrorOffendingObject, below).
  866.         Required desiredTypes:
  867.               typeChar                    brief error message string
  868.     */
  869. /*  0x65727262  */
  870. enum {
  871.     kOSAErrorBriefMessage        = 'errb'
  872. };
  873.  
  874. /*
  875.         This selector is used to determine which application actually got the
  876.         error (if it was the result of an AESend), or the current application
  877.         if ....
  878.         Required desiredTypes:
  879.               typeProcessSerialNumber        PSN of the errant application
  880.               typeChar                    name of the errant application
  881.     */
  882. /*  0x65726170  */
  883. enum {
  884.     kOSAErrorApp                = 'erap'
  885. };
  886.  
  887. /*
  888.         This selector is used to determine any partial result returned by an 
  889.         operation. If an AESend call failed, but a partial result was returned,
  890.         then the partial result may be returned as an AEDesc.
  891.         Required desiredTypes:
  892.               typeBest                    AEDesc of any partial result
  893.     */
  894. /*  0x70746c72   */
  895. enum {
  896.     kOSAErrorPartialResult        = 'ptlr'
  897. };
  898.  
  899. /*
  900.         This selector is used to determine any object which caused the error
  901.         that may have been indicated by an application.  The result is an 
  902.         AEDesc.
  903.         Required desiredTypes:
  904.               typeBest                    AEDesc of any offending object
  905.     */
  906. /*  0x65726f62   */
  907. enum {
  908.     kOSAErrorOffendingObject    = 'erob'
  909. };
  910.  
  911. /*
  912.         This selector is used to determine the type expected by a coercion 
  913.         operation if a type error occurred.
  914.     */
  915. /*  0x65727274   */
  916. enum {
  917.     kOSAErrorExpectedType        = 'errt'
  918. };
  919.  
  920. /*
  921.         This selector is used to determine the source text range (start and 
  922.         end positions) of where the error occurred.
  923.         Required desiredTypes:
  924.               typeOSAErrorRange
  925.     */
  926. /*  0x65726e67  */
  927. enum {
  928.     kOSAErrorRange                = 'erng'
  929. };
  930.  
  931. /*
  932.         An AERecord type containing keyOSASourceStart and keyOSASourceEnd fields
  933.         of type short.
  934.     */
  935. /*  0x65726e67   */
  936. enum {
  937.     typeOSAErrorRange            = 'erng'
  938. };
  939.  
  940. /* Field of a typeOSAErrorRange record of typeShortInteger */
  941. /*  0x73726373    */
  942. enum {
  943.     keyOSASourceStart            = 'srcs'
  944. };
  945.  
  946. /* Field of a typeOSAErrorRange record of typeShortInteger */
  947. /*  0x73726365   */
  948. enum {
  949.     keyOSASourceEnd                = 'srce'
  950. };
  951.  
  952. /* Disposing Script IDs: */
  953. extern pascal OSAError OSADispose(ComponentInstance scriptingComponent, OSAID scriptID)
  954.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0006, 0x7000, 0xA82A);
  955. /*
  956.         OSAComponentFunctionInline(kOSASelectDispose, 4);
  957.         Disposes a script or context.
  958.     
  959.         Errors:
  960.             badComponentInstance    invalid scripting component instance
  961.             errOSASystemError
  962.             errOSAInvalidID
  963.     */
  964. /* Getting and Setting Script Information: */
  965. extern pascal OSAError OSASetScriptInfo(ComponentInstance scriptingComponent, OSAID scriptID, OSType selector, long value)
  966.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0007, 0x7000, 0xA82A);
  967. /*
  968.         OSAComponentFunctionInline(kOSASelectSetScriptInfo, 12);
  969.     
  970.         Errors:
  971.             badComponentInstance    invalid scripting component instance
  972.             errOSASystemError
  973.             errOSAInvalidID
  974.             errOSABadSelector:        selector not supported by scripting component
  975.                                     or selector not for this scriptID
  976.     */
  977. extern pascal OSAError OSAGetScriptInfo(ComponentInstance scriptingComponent, OSAID scriptID, OSType selector, long *result)
  978.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0008, 0x7000, 0xA82A);
  979. /*
  980.         OSAComponentFunctionInline(kOSASelectGetScriptInfo, 12);
  981.     
  982.         Errors:
  983.             badComponentInstance    invalid scripting component instance
  984.             errOSASystemError
  985.             errOSAInvalidID
  986.             errOSABadSelector:        selector not supported by scripting component
  987.                                     or selector not for this scriptID
  988.     */
  989. /* Manipulating the ActiveProc:
  990.  
  991.     Scripting systems will supply default values for these procedures if they
  992.     are not set by the client:
  993. */
  994. typedef pascal OSErr (*OSAActiveProcPtr)(long refCon);
  995.  
  996. #if GENERATINGCFM
  997. typedef UniversalProcPtr OSAActiveUPP;
  998. #else
  999. typedef OSAActiveProcPtr OSAActiveUPP;
  1000. #endif
  1001.  
  1002. enum {
  1003.     uppOSAActiveProcInfo = kPascalStackBased
  1004.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  1005.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(long)))
  1006. };
  1007.  
  1008. #if GENERATINGCFM
  1009. #define NewOSAActiveProc(userRoutine)        \
  1010.         (OSAActiveUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppOSAActiveProcInfo, GetCurrentArchitecture())
  1011. #else
  1012. #define NewOSAActiveProc(userRoutine)        \
  1013.         ((OSAActiveUPP) (userRoutine))
  1014. #endif
  1015.  
  1016. #if GENERATINGCFM
  1017. #define CallOSAActiveProc(userRoutine, refCon)        \
  1018.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppOSAActiveProcInfo, (refCon))
  1019. #else
  1020. #define CallOSAActiveProc(userRoutine, refCon)        \
  1021.         (*(userRoutine))((refCon))
  1022. #endif
  1023.  
  1024. extern pascal OSAError OSASetActiveProc(ComponentInstance scriptingComponent, OSAActiveUPP activeProc, long refCon)
  1025.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0009, 0x7000, 0xA82A);
  1026. /*
  1027.         OSAComponentFunctionInline(kOSASelectSetActiveProc, 8);
  1028.         If activeProc is nil, the default activeProc is used.
  1029.     
  1030.         Errors:
  1031.             badComponentInstance    invalid scripting component instance
  1032.             errOSASystemError
  1033.     */
  1034. extern pascal OSAError OSAGetActiveProc(ComponentInstance scriptingComponent, OSAActiveUPP *activeProc, long *refCon)
  1035.  FIVEWORDINLINE(0x2F3C, 0x8, 0x000A, 0x7000, 0xA82A);
  1036. /*
  1037.         OSAComponentFunctionInline(kOSASelectGetActiveProc, 8);
  1038.     
  1039.         Errors:
  1040.             badComponentInstance    invalid scripting component instance
  1041.             errOSASystemError
  1042.     */
  1043. /**************************************************************************
  1044.     OSA Optional Compiling Interface
  1045. **************************************************************************
  1046.     Scripting components that support the Compiling interface have the 
  1047.     kOSASupportsCompiling bit set in it's ComponentDescription.
  1048. **************************************************************************/
  1049. extern pascal OSAError OSAScriptingComponentName(ComponentInstance scriptingComponent, AEDesc *resultingScriptingComponentName)
  1050.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0102, 0x7000, 0xA82A);
  1051. /*
  1052.         OSAComponentFunctionInline(kOSASelectScriptingComponentName, 4);
  1053.         Given a scripting component, this routine returns the name of that
  1054.         scripting component in a type that is coercable to text (typeChar).
  1055.         The generic scripting component returns the name of the default
  1056.         scripting component.  This name should be sufficient to convey to the
  1057.         user the kind of script (syntax) he is expected to write.
  1058.     
  1059.         Errors:
  1060.             badComponentInstance    invalid scripting component instance
  1061.             errOSASystemError
  1062.     */
  1063. extern pascal OSAError OSACompile(ComponentInstance scriptingComponent, const AEDesc *sourceData, long modeFlags, OSAID *previousAndResultingScriptID)
  1064.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0602, 0x7000, 0xA82A);
  1065. /*
  1066.         OSAComponentFunctionInline(kOSASelectCompile, 12);
  1067.         Coerces input desc (possibly text) into a script's internal format.
  1068.         Once compiled, the script is ready to run.  The modeFlags convey
  1069.         scripting component specific information.  The previous script ID
  1070.         (result parameter) is made to refer to the newly compiled script,
  1071.         unless it was originally kOSANullScript.  In this case a new script
  1072.         ID is created and used.
  1073.     
  1074.         Errors:
  1075.             badComponentInstance    invalid scripting component instance
  1076.             errOSASystemError
  1077.             errAECoercionFail:        sourceData is not compilable
  1078.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1079.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1080.                                     valid on input
  1081.     
  1082.         ModeFlags:
  1083.             kOSAModePreventGetSource
  1084.             kOSAModeCompileIntoContext
  1085.             kOSAModeAugmentContext
  1086.             kOSAModeNeverInteract
  1087.             kOSAModeCanInteract
  1088.             kOSAModeAlwaysInteract
  1089.             kOSAModeCantSwitchLayer
  1090.             kOSAModeDontReconnect
  1091.             kOSAModeDoRecord
  1092.     */
  1093. extern pascal OSAError OSACopyID(ComponentInstance scriptingComponent, OSAID fromID, OSAID *toID)
  1094.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0104, 0x7000, 0xA82A);
  1095. /*
  1096.         OSAComponentFunctionInline(kOSASelectCopyID, 8);
  1097.         If toID is a reference to kOSANullScript then it is updated to have a
  1098.         new scriptID value.  This call can be used to perform undo or revert
  1099.         operations on scripts. 
  1100.     
  1101.         Errors:
  1102.             badComponentInstance    invalid scripting component instance
  1103.             errOSASystemError
  1104.             errOSAInvalidID
  1105.     */
  1106. /**************************************************************************
  1107.     OSA Optional GetSource Interface
  1108. **************************************************************************
  1109.     Scripting components that support the GetSource interface have the 
  1110.     kOSASupportsGetSource bit set in it's ComponentDescription.
  1111. **************************************************************************/
  1112. extern pascal OSAError OSAGetSource(ComponentInstance scriptingComponent, OSAID scriptID, DescType desiredType, AEDesc *resultingSourceData)
  1113.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0201, 0x7000, 0xA82A);
  1114. /*
  1115.         OSAComponentFunctionInline(kOSASelectGetSource, 12);
  1116.         This routine causes a compiled script to be output in a form (possibly
  1117.         text) such that it is suitable to be passed back to OSACompile.
  1118.  
  1119.         Errors:
  1120.             badComponentInstance    invalid scripting component instance
  1121.             errOSASystemError
  1122.             errOSAInvalidID
  1123.             errOSASourceNotAvailable    can't get source for this scriptID
  1124.     */
  1125. /**************************************************************************
  1126.     OSA Optional AECoercion Interface
  1127. **************************************************************************
  1128.     Scripting components that support the AECoercion interface have the 
  1129.     kOSASupportsAECoercion bit set in it's ComponentDescription.
  1130. **************************************************************************/
  1131. extern pascal OSAError OSACoerceFromDesc(ComponentInstance scriptingComponent, const AEDesc *scriptData, long modeFlags, OSAID *resultingScriptID)
  1132.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0301, 0x7000, 0xA82A);
  1133. /*
  1134.         OSAComponentFunctionInline(kOSASelectCoerceFromDesc, 12);
  1135.         This routine causes script data to be coerced into a script value.
  1136.         If the scriptData is an AppleEvent, then the resultingScriptID is a
  1137.         compiled script ID (mode flags for OSACompile may be used in this case).
  1138.         Other scriptData descriptors create script value IDs.
  1139.     
  1140.         Errors:
  1141.             badComponentInstance    invalid scripting component instance
  1142.             errOSASystemError
  1143.     
  1144.         ModeFlags:
  1145.             kOSAModePreventGetSource
  1146.             kOSAModeCompileIntoContext
  1147.             kOSAModeNeverInteract
  1148.             kOSAModeCanInteract
  1149.             kOSAModeAlwaysInteract
  1150.             kOSAModeCantSwitchLayer
  1151.             kOSAModeDontReconnect
  1152.             kOSAModeDoRecord
  1153.     */
  1154. extern pascal OSAError OSACoerceToDesc(ComponentInstance scriptingComponent, OSAID scriptID, DescType desiredType, long modeFlags, AEDesc *result)
  1155.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0302, 0x7000, 0xA82A);
  1156. /*
  1157.         OSAComponentFunctionInline(kOSASelectCoerceToDesc, 16);
  1158.         This routine causes a script value to be coerced into any desired form.
  1159.         If the scriptID denotes a compiled script, then it may be coerced to 
  1160.         typeAppleEvent.
  1161.     
  1162.         Errors:
  1163.             badComponentInstance    invalid scripting component instance
  1164.             errOSASystemError
  1165.             errOSAInvalidID
  1166.     */
  1167. /**************************************************************************
  1168.     OSA Optional AESending Interface
  1169. **************************************************************************
  1170.     Scripting components that support the AESending interface have the 
  1171.     kOSASupportsAESending bit set in it's ComponentDescription.
  1172. **************************************************************************/
  1173. /*
  1174.     Scripting systems will supply default values for these procedures if they
  1175.     are not set by the client:
  1176. */
  1177. extern pascal OSAError OSASetSendProc(ComponentInstance scriptingComponent, OSASendUPP sendProc, long refCon)
  1178.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0401, 0x7000, 0xA82A);
  1179. /*
  1180.         OSAComponentFunctionInline(kOSASelectSetSendProc, 8);
  1181.         If sendProc is nil, the default sendProc is used.
  1182.     
  1183.         Errors:
  1184.             badComponentInstance    invalid scripting component instance
  1185.             errOSASystemError
  1186.     */
  1187. extern pascal OSAError OSAGetSendProc(ComponentInstance scriptingComponent, OSASendUPP *sendProc, long *refCon)
  1188.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0402, 0x7000, 0xA82A);
  1189. /*
  1190.         OSAComponentFunctionInline(kOSASelectGetSendProc, 8);
  1191.     
  1192.         Errors:
  1193.             badComponentInstance    invalid scripting component instance
  1194.             errOSASystemError
  1195.     */
  1196. extern pascal OSAError OSASetCreateProc(ComponentInstance scriptingComponent, OSACreateAppleEventUPP createProc, long refCon)
  1197.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0403, 0x7000, 0xA82A);
  1198. /*
  1199.         OSAComponentFunctionInline(kOSASelectSetCreateProc, 8);
  1200.         If createProc is nil, the default createProc is used.
  1201.     
  1202.         Errors:
  1203.             badComponentInstance    invalid scripting component instance
  1204.             errOSASystemError
  1205.     */
  1206. extern pascal OSAError OSAGetCreateProc(ComponentInstance scriptingComponent, OSACreateAppleEventUPP *createProc, long *refCon)
  1207.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0404, 0x7000, 0xA82A);
  1208. /*
  1209.         OSAComponentFunctionInline(kOSASelectGetCreateProc, 8);
  1210.     
  1211.         Errors:
  1212.             badComponentInstance    invalid scripting component instance
  1213.             errOSASystemError
  1214.     */
  1215. extern pascal OSAError OSASetDefaultTarget(ComponentInstance scriptingComponent, const AEAddressDesc *target)
  1216.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0405, 0x7000, 0xA82A);
  1217. /*
  1218.         OSAComponentFunctionInline(kOSASelectSetDefaultTarget, 4);
  1219.         This routine sets the default target application for AE sending.
  1220.         It also establishes the default target from which terminologies come.
  1221.         It is effectively like having an AppleScript "tell" statement around
  1222.         the entire program.  If this routine is not called, or if the target 
  1223.         is a null AEDesc, then the current application is the default target.
  1224.     
  1225.         Errors:
  1226.             badComponentInstance    invalid scripting component instance
  1227.             errOSASystemError
  1228.     */
  1229. /**************************************************************************
  1230.     OSA Optional Recording Interface
  1231. **************************************************************************
  1232.     Scripting components that support the Recording interface have the 
  1233.     kOSASupportsRecording bit set in it's ComponentDescription.
  1234. **************************************************************************/
  1235. extern pascal OSAError OSAStartRecording(ComponentInstance scriptingComponent, OSAID *compiledScriptToModifyID)
  1236.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0501, 0x7000, 0xA82A);
  1237. /*
  1238.         OSAComponentFunctionInline(kOSASelectStartRecording, 4);
  1239.         Starts recording.  If compiledScriptToModifyID is kOSANullScript, a
  1240.         new script ID is created and returned.  If the current application has
  1241.         a handler for the kOSARecordedText event, then kOSARecordedText events
  1242.         are sent to the application containing the text of each AppleEvent 
  1243.         recorded.
  1244.     
  1245.         Errors:
  1246.             badComponentInstance    invalid scripting component instance
  1247.             errOSASystemError
  1248.             errOSAInvalidID
  1249.             errOSARecordingIsAlreadyOn
  1250.     */
  1251. extern pascal OSAError OSAStopRecording(ComponentInstance scriptingComponent, OSAID compiledScriptID)
  1252.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0502, 0x7000, 0xA82A);
  1253. /*
  1254.         OSAComponentFunctionInline(kOSASelectStopRecording, 4);
  1255.         If compiledScriptID is not being recorded into or recording is not
  1256.         currently on, no error is returned.
  1257.     
  1258.         Errors:
  1259.             badComponentInstance    invalid scripting component instance
  1260.             errOSASystemError
  1261.             errOSAInvalidID
  1262.     */
  1263. /**************************************************************************
  1264.     OSA Optional Convenience Interface
  1265. **************************************************************************
  1266.     Scripting components that support the Convenience interface have the 
  1267.     kOSASupportsConvenience bit set in it's ComponentDescription.
  1268. **************************************************************************/
  1269. extern pascal OSAError OSALoadExecute(ComponentInstance scriptingComponent, const AEDesc *scriptData, OSAID contextID, long modeFlags, OSAID *resultingScriptValueID)
  1270.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0601, 0x7000, 0xA82A);
  1271. /*
  1272.         OSAComponentFunctionInline(kOSASelectLoadExecute, 16);
  1273.         This routine is effectively equivalent to calling OSALoad followed by
  1274.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1275.         resulting value ID is retained.
  1276.     
  1277.         Errors:
  1278.             badComponentInstance        invalid scripting component instance
  1279.             errOSASystemError
  1280.             errOSABadStorageType:        scriptData not for this scripting component
  1281.             errOSACorruptData:            data seems to be corrupt
  1282.             errOSADataFormatObsolete    script data format is no longer supported
  1283.             errOSADataFormatTooNew        script data format is from a newer version
  1284.             errOSAInvalidID
  1285.             errOSAScriptError:            the executing script got an error
  1286.     
  1287.         ModeFlags:
  1288.             kOSAModeNeverInteract
  1289.             kOSAModeCanInteract
  1290.             kOSAModeAlwaysInteract
  1291.             kOSAModeCantSwitchLayer
  1292.             kOSAModeDontReconnect
  1293.             kOSAModeDoRecord
  1294.     */
  1295. extern pascal OSAError OSACompileExecute(ComponentInstance scriptingComponent, const AEDesc *sourceData, OSAID contextID, long modeFlags, OSAID *resultingScriptValueID)
  1296.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0602, 0x7000, 0xA82A);
  1297. /*
  1298.         OSAComponentFunctionInline(kOSASelectCompileExecute, 16);
  1299.         This routine is effectively equivalent to calling OSACompile followed by
  1300.         OSAExecute.  After execution, the compiled source is disposed.  Only the
  1301.         resulting value ID is retained.
  1302.     
  1303.         Errors:
  1304.             badComponentInstance    invalid scripting component instance
  1305.             errOSASystemError
  1306.             errAECoercionFail:        sourceData is not compilable
  1307.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1308.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1309.                                     valid on input
  1310.             errOSAScriptError:        the executing script got an error
  1311.     
  1312.         ModeFlags:
  1313.             kOSAModeNeverInteract
  1314.             kOSAModeCanInteract
  1315.             kOSAModeAlwaysInteract
  1316.             kOSAModeCantSwitchLayer
  1317.             kOSAModeDontReconnect
  1318.             kOSAModeDoRecord
  1319.     */
  1320. extern pascal OSAError OSADoScript(ComponentInstance scriptingComponent, const AEDesc *sourceData, OSAID contextID, DescType desiredType, long modeFlags, AEDesc *resultingText)
  1321.  FIVEWORDINLINE(0x2F3C, 0x14, 0x0603, 0x7000, 0xA82A);
  1322. /*
  1323.         OSAComponentFunctionInline(kOSASelectDoScript, 20);
  1324.         This routine is effectively equivalent to calling OSACompile followed by
  1325.         OSAExecute and then OSADisplay.  After execution, the compiled source
  1326.         and the resulting value are is disposed.  Only the resultingText
  1327.         descriptor is retained.  If a script error occur during processing, the 
  1328.         resultingText gets the error message of the error, and errOSAScriptError
  1329.         is returned.  OSAScriptError may still be used to extract more 
  1330.         information about the particular error.
  1331.     
  1332.         Errors:
  1333.             badComponentInstance    invalid scripting component instance
  1334.             errOSASystemError
  1335.             errAECoercionFail:        sourceData is not compilable or 
  1336.                                     desiredType not supported by scripting component
  1337.             errOSAScriptError:        sourceData was a bad script (syntax error)
  1338.             errOSAInvalidID:        previousAndResultingCompiledScriptID was not
  1339.                                     valid on input
  1340.             errOSAScriptError:        the executing script got an error
  1341.     
  1342.         ModeFlags:
  1343.             kOSAModeNeverInteract
  1344.             kOSAModeCanInteract
  1345.             kOSAModeAlwaysInteract
  1346.             kOSAModeCantSwitchLayer
  1347.             kOSAModeDontReconnect
  1348.             kOSAModeDoRecord
  1349.             kOSAModeDisplayForHumans
  1350.     */
  1351. /**************************************************************************
  1352.     OSA Optional Dialects Interface
  1353. **************************************************************************
  1354.     Scripting components that support the Dialects interface have the 
  1355.     kOSASupportsDialects bit set in it's ComponentDescription.
  1356. **************************************************************************/
  1357. /*
  1358.     These calls allows an scripting component that supports different dialects
  1359.     to dynamically switch between those dialects.  Although this interface is
  1360.     specified, the particular dialect codes are scripting component dependent.
  1361. */
  1362. extern pascal OSAError OSASetCurrentDialect(ComponentInstance scriptingComponent, short dialectCode)
  1363.  FIVEWORDINLINE(0x2F3C, 0x2, 0x0701, 0x7000, 0xA82A);
  1364. /*
  1365.         OSAComponentFunctionInline(kOSASelectSetCurrentDialect, 2);
  1366.     
  1367.         Errors:
  1368.             badComponentInstance    invalid scripting component instance
  1369.             errOSASystemError
  1370.             errOSANoSuchDialect:    invalid dialectCode
  1371.     */
  1372. extern pascal OSAError OSAGetCurrentDialect(ComponentInstance scriptingComponent, short *resultingDialectCode)
  1373.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0702, 0x7000, 0xA82A);
  1374. /*
  1375.         OSAComponentFunctionInline(kOSASelectGetCurrentDialect, 4);
  1376.     
  1377.         Errors:
  1378.             badComponentInstance    invalid scripting component instance
  1379.             errOSASystemError
  1380.     */
  1381. extern pascal OSAError OSAAvailableDialects(ComponentInstance scriptingComponent, AEDesc *resultingDialectInfoList)
  1382.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0703, 0x7000, 0xA82A);
  1383. /*
  1384.         OSAComponentFunctionInline(kOSASelectAvailableDialects, 4);
  1385.         This call return an AEList containing information about each of the
  1386.         currently available dialects of a scripting component.  Each item
  1387.         is an AERecord of typeOSADialectInfo that contains at least the fields
  1388.         keyOSADialectName, keyOSADialectCode, KeyOSADialectLangCode and 
  1389.         keyOSADialectScriptCode.
  1390.     
  1391.         Errors:
  1392.             badComponentInstance    invalid scripting component instance
  1393.             errOSASystemError
  1394.     */
  1395. extern pascal OSAError OSAGetDialectInfo(ComponentInstance scriptingComponent, short dialectCode, OSType selector, AEDesc *resultingDialectInfo)
  1396.  FIVEWORDINLINE(0x2F3C, 0xA, 0x0704, 0x7000, 0xA82A);
  1397. /*
  1398.         OSAComponentFunctionInline(kOSASelectGetDialectInfo, 10);
  1399.         This call gives information about the specified dialect of a scripting
  1400.         component. It returns an AEDesc whose type depends on the selector 
  1401.         specified. Available selectors are the same as the field keys for a
  1402.         dialect info record. The type of AEDesc returned is the same as the 
  1403.         type of the field that has same key as the selector.
  1404.     
  1405.         Errors:
  1406.             badComponentInstance    invalid scripting component instance
  1407.             errOSASystemError
  1408.              errOSABadSelector
  1409.             errOSANoSuchDialect:    invalid dialectCode
  1410.     */
  1411. extern pascal OSAError OSAAvailableDialectCodeList(ComponentInstance scriptingComponent, AEDesc *resultingDialectCodeList)
  1412.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0705, 0x7000, 0xA82A);
  1413. /*
  1414.         OSAComponentFunctionInline(kOSASelectAvailableDialectCodeList, 4);
  1415.         This is alternative to OSAGetAvailableDialectCodeList. Use this call
  1416.         and  OSAGetDialectInfo to get information on dialects.
  1417.         This call return an AEList containing dialect code for each of the
  1418.         currently available dialects of a scripting component. Each dialect
  1419.         code is a short integer of type typeShortInteger.
  1420.     
  1421.         Errors:
  1422.             badComponentInstance    invalid scripting component instance
  1423.             errOSASystemError
  1424.  
  1425.         Type of a dialect info record containing at least keyOSADialectName
  1426.         and keyOSADialectCode fields.
  1427.  
  1428.         keys for dialect info record, also used as selectors to OSAGetDialectInfo.
  1429.  
  1430.         Field of a typeOSADialectInfo record of typeChar.
  1431.         Field of a typeOSADialectInfo record of typeShortInteger.
  1432.         Field of a typeOSADialectInfo record of typeShortInteger.
  1433.         Field of a typeOSADialectInfo record of typeShortInteger.
  1434.     */
  1435. /**************************************************************************
  1436.     OSA Optional Event Handling Interface
  1437. **************************************************************************
  1438.     Scripting components that support the Event Handling interface have the 
  1439.     kOSASupportsEventHandling bit set in it's ComponentDescription.
  1440. **************************************************************************/
  1441. extern pascal OSAError OSASetResumeDispatchProc(ComponentInstance scriptingComponent, AEEventHandlerUPP resumeDispatchProc, long refCon)
  1442.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0801, 0x7000, 0xA82A);
  1443. /*
  1444.         OSAComponentFunctionInline(kOSASelectSetResumeDispatchProc, 8);
  1445.         This function is used to set the ResumeDispatchProc that will be used
  1446.         by OSAExecuteEvent and OSADoEvent if either no event handler can be
  1447.         found in the context, or the context event hander "continues" control
  1448.         onward. The two constants kOSAUseStandardDispatch and kOSANoDispatch
  1449.         may also be passed to this routine indicating that the handler registered
  1450.         in the application with AEInstallEventHandler should be used, or no
  1451.         dispatch should occur, respectively.
  1452.     
  1453.         Errors:
  1454.             badComponentInstance    invalid scripting component instance
  1455.             errOSASystemError
  1456.     */
  1457.  
  1458. enum {
  1459.     kOSAUseStandardDispatch        = kAEUseStandardDispatch
  1460. };
  1461.  
  1462. /*
  1463.         Special ResumeDispatchProc constant which may be passed to 
  1464.         OSASetResumeDispatchProc indicating that the handler registered
  1465.         in the application with AEInstallEventHandler should be used.
  1466.         
  1467.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1468.                 doesn't allow pointer types to be assigned to an enum.  All
  1469.                 constants must be assigned as enums to translate properly to
  1470.                 Pascal.
  1471.     */
  1472. enum {
  1473.     kOSANoDispatch                = kAENoDispatch
  1474. };
  1475.  
  1476. /*
  1477.         Special ResumeDispatchProc constant which may be passed to 
  1478.         OSASetResumeDispatchProc indicating that no dispatch should occur.
  1479.         
  1480.         NOTE:    Had to remove the cast (AEEventHandlerUPP).  The C compiler
  1481.                 doesn't allow pointer types to be assigned to an enum.  All
  1482.                 constants must be assigned as enums to translate properly to
  1483.                 Pascal.
  1484.     */
  1485. enum {
  1486.     kOSADontUsePhac                = 0x0001
  1487. };
  1488.  
  1489. /*
  1490.         Special refCon constant that may be given to OSASetResumeDispatchProc
  1491.         only when kOSAUseStandardDispatch is used as the ResumeDispatchProc.
  1492.         This causes the standard dispatch to be performed, except the phac
  1493.         handler is not called.  This is useful during tinkerability, when
  1494.         the phac handler is used to lookup a context associated with an event's 
  1495.         direct parameter, and call OSAExecuteEvent or OSADoEvent.  Failure to
  1496.         bypass the phac handler would result in an infinite loop.
  1497.     */
  1498. extern pascal OSAError OSAGetResumeDispatchProc(ComponentInstance scriptingComponent, AEEventHandlerUPP *resumeDispatchProc, long *refCon)
  1499.  FIVEWORDINLINE(0x2F3C, 0x8, 0x0802, 0x7000, 0xA82A);
  1500. /*
  1501.         OSAComponentFunctionInline(kOSASelectGetResumeDispatchProc, 8);
  1502.         Returns the registered ResumeDispatchProc.  If no ResumeDispatchProc has
  1503.         been registered, then kOSAUseStandardDispatch (the default) is returned.
  1504.     
  1505.         Errors:
  1506.             badComponentInstance    invalid scripting component instance
  1507.             errOSASystemError
  1508.     */
  1509. extern pascal OSAError OSAExecuteEvent(ComponentInstance scriptingComponent, const AppleEvent *theAppleEvent, OSAID contextID, long modeFlags, OSAID *resultingScriptValueID)
  1510.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0803, 0x7000, 0xA82A);
  1511. /*
  1512.         OSAComponentFunctionInline(kOSASelectExecuteEvent, 16);
  1513.         This call is similar to OSAExecute except the initial command to
  1514.         execute comes in the form of an AppleEvent.  If the contextID
  1515.         defines any event handlers for that event, they are used to process
  1516.         the event.  If no event handler can be found in the context
  1517.         errAEEventNotHandled is returned.  If an event handler is found and
  1518.         the hander "continues" control onward, the ResumeDispatchProc
  1519.         (registered with OSASetResumeDispatchProc, above) is called given the
  1520.         AppleEvent.  The result is returned as a scriptValueID.
  1521.     
  1522.         Errors:
  1523.             badComponentInstance    invalid scripting component instance
  1524.             errOSASystemError
  1525.             errOSAInvalidID
  1526.             errOSAScriptError:        the executing script got an error
  1527.             errAEEventNotHandled:    no handler for event in contextID
  1528.     
  1529.         ModeFlags:
  1530.             kOSAModeNeverInteract
  1531.             kOSAModeCanInteract
  1532.             kOSAModeAlwaysInteract
  1533.             kOSAModeCantSwitchLayer
  1534.             kOSAModeDontReconnect
  1535.             kOSAModeDoRecord
  1536.     */
  1537. extern pascal OSAError OSADoEvent(ComponentInstance scriptingComponent, const AppleEvent *theAppleEvent, OSAID contextID, long modeFlags, AppleEvent *reply)
  1538.  FIVEWORDINLINE(0x2F3C, 0x10, 0x0804, 0x7000, 0xA82A);
  1539. /*
  1540.         OSAComponentFunctionInline(kOSASelectDoEvent, 16);
  1541.         This call is similar to OSADoScript except the initial command to
  1542.         execute comes in the form of an AppleEvent, and the result is an 
  1543.         AppleEvent reply record.  If the contextID defines any event handlers
  1544.         for that event, they are used to process the event.  If no event handler
  1545.         can be found in the context errAEEventNotHandled is returned.  If an
  1546.         event handler is found and the hander "continues" control onward, the
  1547.         ResumeDispatchProc (registered with OSASetResumeDispatchProc, above) is
  1548.         called given the AppleEvent.  The result is returned in the form of an
  1549.         AppleEvent reply descriptor. If at any time the script gets an error, or
  1550.         if the ResumeDispatchProc returns a reply event indicating an error,
  1551.         then the OSADoEvent call itself returns an error reply (i.e. OSADoEvent
  1552.         should never return errOSAScriptError).  Any error result returned by
  1553.         the ResumeDispatchProc will be returned by OSADoEvent.
  1554.     
  1555.         Errors:
  1556.             badComponentInstance    invalid scripting component instance
  1557.             errOSASystemError
  1558.             errOSAInvalidID
  1559.             errAEEventNotHandled:    no handler for event in contextID
  1560.     
  1561.         ModeFlags:
  1562.             kOSAModeNeverInteract
  1563.             kOSAModeCanInteract
  1564.             kOSAModeAlwaysInteract
  1565.             kOSAModeCantSwitchLayer
  1566.             kOSAModeDontReconnect
  1567.             kOSAModeDoRecord
  1568.     */
  1569. extern pascal OSAError OSAMakeContext(ComponentInstance scriptingComponent, const AEDesc *contextName, OSAID parentContext, OSAID *resultingContextID)
  1570.  FIVEWORDINLINE(0x2F3C, 0xC, 0x0805, 0x7000, 0xA82A);
  1571. /*
  1572.         OSAComponentFunctionInline(kOSASelectMakeContext, 12);
  1573.         Makes a new empty context which may be passed to OSAExecute or 
  1574.         OSAExecuteEvent.  If contextName is typeNull, an unnamed context is
  1575.         created. If parentContext is kOSANullScript then the resulting context
  1576.         does not inherit bindings from any other context.
  1577.     
  1578.         Errors:
  1579.             badComponentInstance    invalid scripting component instance
  1580.             errOSASystemError
  1581.             errOSAInvalidID
  1582.             errAECoercionFail:        contextName is invalid
  1583.     */
  1584.  
  1585. #ifdef __CFM68K__
  1586. #pragma lib_export off
  1587. #endif
  1588.  
  1589. #if GENERATINGPOWERPC
  1590. #pragma options align=reset
  1591. #endif
  1592.  
  1593. #ifdef __cplusplus
  1594. }
  1595. #endif
  1596.  
  1597. #endif /* __OSA__ */
  1598.